var sysuser = {
	baseurl : "index.php?file=sysuser",
	add:function(){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=add&nocache="+Math.random(),
			title: "新增管理员",
			width: 400,
			height: 263,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	edit:function(id){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=edit&id="+id+"&nocache="+Math.random(),
			title: "编辑管理员",
			width: 400,
			height: 263,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	del:function(id){
		$.messager.confirm("删除提示","你真的要删除吗？删除后不可恢复",function(res){
			if(res){
				result = $.evalJSON($.ajax({
					type: "get",url:"index.php?file=sysuser&action=delete&id="+id+"&nocache="+Math.random(),async: false
				}).responseText);
				if(result.status=="success"){
					window.location.reload();
				}else{
					$.messager.alert('提示信息', "数据删除失败，请联系系统管理员" ,"info");
				}
			}
		});
	},
	addDepartment:function(){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=addDepartment&nocache="+Math.random(),
			title: "添加部门",
			width: 400,
			height: 250,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	editDepartment:function(id){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=editDepartment&bid="+id+"&nocache="+Math.random(),
			title: "编辑部门",
			width: 400,
			height: 250,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	delDepartment:function(id){
		$.messager.confirm("删除提示","你真的要删除吗？删除后不可恢复",function(res){
			if(res){
				result = $.evalJSON($.ajax({
					type: "get",url:"index.php?file=sysuser&action=deleteDepartment&bid="+id+"&nocache="+Math.random(),async: false
				}).responseText);
				if(result.status=="success"){
					window.location.reload();
				}else{
					$.messager.alert('提示信息', "数据删除失败，请联系系统管理员" ,"info");
				}
			}
		});
	},
	addApparatus:function(){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=addApparatus&nocache="+Math.random(),
			title: "添加机构",
			width: 400,
			height: 150,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	editApparatus:function(id){
		if($("#window").length==1) $("#window").remove();
		$("body").append("<div id='window'></div>");
		$("#window").window({
			href: sysuser.baseurl + "&action=editApparatus&jid="+id+"&nocache="+Math.random(),
			title: "编辑机构",
			width: 400,
			height: 180,
			cache:false,
			modal: true,
			shadow: false,
		    collapsible:false,
		    minimizable:false,
		    maximizable:false
		});
	},
	delApparatus:function(id){
		$.messager.confirm("删除提示","你真的要删除吗？删除后不可恢复",function(res){
			if(res){
				result = $.evalJSON($.ajax({
					type: "get",url:"index.php?file=sysuser&action=deleteApparatus&jid="+id+"&nocache="+Math.random(),async: false
				}).responseText);
				if(result.status=="success"){
					window.location.reload();
				}else{
					$.messager.alert('提示信息', "数据删除失败，请联系系统管理员" ,"info");
				}
			}
		});
	},
	GroupChangueModule:function(object){
		var thechecked = $(object).attr("checked");
		if(!thechecked){
			$("#theForm").unCheckCheckboxes(".pid_"+$(object).val(), true);
			return;
		}else{
			$("#theForm").checkCheckboxes(".pid_"+$(object).val(), true);
		}
	},
	GroupChangueChildren:function(object){
		var relevance = $(object).attr("relevance");
		var parent_id = $(object).attr("pid");
		if(relevance>0){
			$("#module_"+relevance).attr("checked",true);
			$("#module_"+parent_id).attr("checked",true);
			return;
		}else{
			var thechecked = $(object).attr("checked");
			if(!thechecked){
				$("#theForm").unCheckCheckboxes(".rele_"+$(object).val(), true);
				return;
			}else{
				$("#module_"+parent_id).attr("checked",true);
				return;
			}
		}
	},
	GroupDel:function(gid){
		$.messager.confirm("删除提示","你真的要删除吗？删除后不可恢复",function(res){
			if(res){
				result = $.evalJSON($.ajax({
					type: "get",url:"index.php?file=sysgroup&action=delete&gid="+gid+"&nocache="+Math.random(),async: false
				}).responseText);
				if(result.status=="success"){
					window.location.reload();
				}else{
					$.messager.alert('提示信息', "数据删除失败，请联系系统管理员" ,"info");
				}
			}
		});
	}
};